<!DOCTYPE html>
<html lang="zh_Hans">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">
  <meta name="baidu-site-verification" content="cpmFX379Hw.chiangyung.github.io">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">
  <link rel="stylesheet" href="/lib/pace/pace-theme-minimal.min.css">
  <script src="/lib/pace/pace.min.js"></script>

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"chiangyung.github.io","root":"/","scheme":"Gemini","version":"7.8.0","exturl":false,"sidebar":{"position":"left","Pisces | Gemini":240,"width":240,"display":"always","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":true,"show_result":true,"style":"default"},"back2top":{"enable":true,"sidebar":true,"scrollpercent":true},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="本文给出了LBM-MPI的测试程序。">
<meta property="og:type" content="article">
<meta property="og:title" content="LBM-MPI测试程序">
<meta property="og:url" content="https://chiangyung.github.io/posts/35856/index.html">
<meta property="og:site_name" content="姜勇的博客">
<meta property="og:description" content="本文给出了LBM-MPI的测试程序。">
<meta property="article:published_time" content="2020-01-06T04:40:22.000Z">
<meta property="article:modified_time" content="2020-04-25T14:30:39.573Z">
<meta property="article:author" content="ChiangYung">
<meta property="article:tag" content="Programming">
<meta property="article:tag" content="C++">
<meta property="article:tag" content="MPI">
<meta property="article:tag" content="Parallel Computing">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="https://chiangyung.github.io/posts/35856/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh_Hans'
  };
</script>

  <title>LBM-MPI测试程序 | 姜勇的博客</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

<link rel="alternate" href="/atom.xml" title="姜勇的博客" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">姜勇的博客</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签<span class="badge">26</span></a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类<span class="badge">3</span></a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档<span class="badge">41</span></a>

  </li>
        <li class="menu-item menu-item-合集">

    <a href="/collections/" rel="section"><i class="fa fa-folder fa-fw"></i>合集</a>

  </li>
        <li class="menu-item menu-item-课程">

    <a href="/course/" rel="section"><i class="fa fa-graduation-cap fa-fw"></i>课程</a>

  </li>
        <li class="menu-item menu-item-读书">

    <a href="/books/" rel="section"><i class="fa fa-book fa-fw"></i>读书</a>

  </li>
        <li class="menu-item menu-item-旅行">

    <a href="/travels/" rel="section"><i class="fa fa-train fa-fw"></i>旅行</a>

  </li>
        <li class="menu-item menu-item-观影">

    <a href="/videos/" rel="section"><i class="fa fa-tv fa-fw"></i>观影</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="reading-progress-bar"></div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh_Hans">
    <link itemprop="mainEntityOfPage" href="https://chiangyung.github.io/posts/35856/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/upload/E8.png">
      <meta itemprop="name" content="ChiangYung">
      <meta itemprop="description" content="我于蒙昧之中，探寻宇宙万物。">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="姜勇的博客">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          LBM-MPI测试程序
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-01-06 12:40:22" itemprop="dateCreated datePublished" datetime="2020-01-06T12:40:22+08:00">2020-01-06</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2020-04-25 22:30:39" itemprop="dateModified" datetime="2020-04-25T22:30:39+08:00">2020-04-25</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Programming/" itemprop="url" rel="index"><span itemprop="name">Programming</span></a>
                </span>
            </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>12k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>11 分钟</span>
            </span>
            <div class="post-description">本文给出了LBM-MPI的测试程序。</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br><span class="line">255</span><br><span class="line">256</span><br><span class="line">257</span><br><span class="line">258</span><br><span class="line">259</span><br><span class="line">260</span><br><span class="line">261</span><br><span class="line">262</span><br><span class="line">263</span><br><span class="line">264</span><br><span class="line">265</span><br><span class="line">266</span><br><span class="line">267</span><br><span class="line">268</span><br><span class="line">269</span><br><span class="line">270</span><br><span class="line">271</span><br><span class="line">272</span><br><span class="line">273</span><br><span class="line">274</span><br><span class="line">275</span><br><span class="line">276</span><br><span class="line">277</span><br><span class="line">278</span><br><span class="line">279</span><br><span class="line">280</span><br><span class="line">281</span><br><span class="line">282</span><br><span class="line">283</span><br><span class="line">284</span><br><span class="line">285</span><br><span class="line">286</span><br><span class="line">287</span><br><span class="line">288</span><br><span class="line">289</span><br><span class="line">290</span><br><span class="line">291</span><br><span class="line">292</span><br><span class="line">293</span><br><span class="line">294</span><br><span class="line">295</span><br><span class="line">296</span><br><span class="line">297</span><br><span class="line">298</span><br><span class="line">299</span><br><span class="line">300</span><br><span class="line">301</span><br><span class="line">302</span><br><span class="line">303</span><br><span class="line">304</span><br><span class="line">305</span><br><span class="line">306</span><br><span class="line">307</span><br><span class="line">308</span><br><span class="line">309</span><br><span class="line">310</span><br><span class="line">311</span><br><span class="line">312</span><br><span class="line">313</span><br><span class="line">314</span><br><span class="line">315</span><br><span class="line">316</span><br><span class="line">317</span><br><span class="line">318</span><br><span class="line">319</span><br><span class="line">320</span><br><span class="line">321</span><br><span class="line">322</span><br><span class="line">323</span><br><span class="line">324</span><br><span class="line">325</span><br><span class="line">326</span><br><span class="line">327</span><br><span class="line">328</span><br><span class="line">329</span><br><span class="line">330</span><br><span class="line">331</span><br><span class="line">332</span><br><span class="line">333</span><br><span class="line">334</span><br><span class="line">335</span><br><span class="line">336</span><br><span class="line">337</span><br><span class="line">338</span><br><span class="line">339</span><br><span class="line">340</span><br><span class="line">341</span><br><span class="line">342</span><br><span class="line">343</span><br><span class="line">344</span><br><span class="line">345</span><br><span class="line">346</span><br><span class="line">347</span><br><span class="line">348</span><br><span class="line">349</span><br><span class="line">350</span><br><span class="line">351</span><br><span class="line">352</span><br><span class="line">353</span><br><span class="line">354</span><br><span class="line">355</span><br><span class="line">356</span><br><span class="line">357</span><br><span class="line">358</span><br><span class="line">359</span><br><span class="line">360</span><br><span class="line">361</span><br><span class="line">362</span><br><span class="line">363</span><br><span class="line">364</span><br><span class="line">365</span><br><span class="line">366</span><br><span class="line">367</span><br><span class="line">368</span><br><span class="line">369</span><br><span class="line">370</span><br><span class="line">371</span><br><span class="line">372</span><br><span class="line">373</span><br><span class="line">374</span><br><span class="line">375</span><br><span class="line">376</span><br><span class="line">377</span><br><span class="line">378</span><br><span class="line">379</span><br><span class="line">380</span><br><span class="line">381</span><br><span class="line">382</span><br><span class="line">383</span><br><span class="line">384</span><br><span class="line">385</span><br><span class="line">386</span><br><span class="line">387</span><br><span class="line">388</span><br><span class="line">389</span><br><span class="line">390</span><br><span class="line">391</span><br><span class="line">392</span><br><span class="line">393</span><br><span class="line">394</span><br><span class="line">395</span><br><span class="line">396</span><br><span class="line">397</span><br><span class="line">398</span><br><span class="line">399</span><br><span class="line">400</span><br><span class="line">401</span><br><span class="line">402</span><br><span class="line">403</span><br><span class="line">404</span><br><span class="line">405</span><br><span class="line">406</span><br><span class="line">407</span><br><span class="line">408</span><br><span class="line">409</span><br><span class="line">410</span><br><span class="line">411</span><br><span class="line">412</span><br><span class="line">413</span><br><span class="line">414</span><br><span class="line">415</span><br><span class="line">416</span><br><span class="line">417</span><br><span class="line">418</span><br><span class="line">419</span><br><span class="line">420</span><br><span class="line">421</span><br><span class="line">422</span><br><span class="line">423</span><br><span class="line">424</span><br><span class="line">425</span><br><span class="line">426</span><br><span class="line">427</span><br><span class="line">428</span><br><span class="line">429</span><br><span class="line">430</span><br><span class="line">431</span><br><span class="line">432</span><br><span class="line">433</span><br><span class="line">434</span><br><span class="line">435</span><br><span class="line">436</span><br><span class="line">437</span><br><span class="line">438</span><br><span class="line">439</span><br><span class="line">440</span><br><span class="line">441</span><br><span class="line">442</span><br><span class="line">443</span><br><span class="line">444</span><br><span class="line">445</span><br><span class="line">446</span><br><span class="line">447</span><br><span class="line">448</span><br><span class="line">449</span><br><span class="line">450</span><br><span class="line">451</span><br><span class="line">452</span><br><span class="line">453</span><br><span class="line">454</span><br><span class="line">455</span><br><span class="line">456</span><br><span class="line">457</span><br><span class="line">458</span><br><span class="line">459</span><br><span class="line">460</span><br><span class="line">461</span><br><span class="line">462</span><br><span class="line">463</span><br><span class="line">464</span><br><span class="line">465</span><br><span class="line">466</span><br><span class="line">467</span><br><span class="line">468</span><br><span class="line">469</span><br><span class="line">470</span><br><span class="line">471</span><br><span class="line">472</span><br><span class="line">473</span><br><span class="line">474</span><br><span class="line">475</span><br><span class="line">476</span><br><span class="line">477</span><br><span class="line">478</span><br><span class="line">479</span><br><span class="line">480</span><br><span class="line">481</span><br><span class="line">482</span><br><span class="line">483</span><br><span class="line">484</span><br><span class="line">485</span><br><span class="line">486</span><br><span class="line">487</span><br><span class="line">488</span><br><span class="line">489</span><br><span class="line">490</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;stdlib.h&gt;  </span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;stdio.h&gt;  </span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;math.h&gt;  </span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;string.h&gt;  </span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;sys/time.h&gt;  </span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;time.h&gt;  </span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;math.h&gt;  </span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;omp.h&gt;  </span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;mpi.h&gt;  </span></span></span><br><span class="line">  </span><br><span class="line"><span class="comment">//#include &lt;md.h&gt;  </span></span><br><span class="line">  </span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> NDIM 3  </span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> RATE 4  </span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> MAXN 200  </span></span><br><span class="line">  </span><br><span class="line"><span class="comment">//定义MPI通信组和通信域  </span></span><br><span class="line"><span class="keyword">int</span> Size,Myid;  </span><br><span class="line">MPI_Group group_LBM, group_DEM, group_WORLD;  </span><br><span class="line">MPI_Comm comm_LBM, comm_DEM;  </span><br><span class="line"><span class="keyword">int</span> *rank_LBM, * rank_DEM;  </span><br><span class="line"><span class="keyword">int</span> N;  </span><br><span class="line">  </span><br><span class="line"><span class="comment">//MPI区域划分  </span></span><br><span class="line"><span class="keyword">int</span> DEM_Prsnum[NDIM],DEM_Prsid[NDIM];  </span><br><span class="line"><span class="keyword">int</span> LBM_Prsnum[NDIM],LBM_Prsid[NDIM];  </span><br><span class="line">  </span><br><span class="line"><span class="comment">//LBM数据  </span></span><br><span class="line"><span class="keyword">int</span> *LBM_Data,LBM_N;  </span><br><span class="line"><span class="keyword">int</span> *LBM_Send,*LBM_Recv;  </span><br><span class="line"><span class="keyword">int</span> LBM_Dir[NDIM][<span class="number">2</span>];  </span><br><span class="line"><span class="keyword">int</span> LBMtoDEM;  </span><br><span class="line">  </span><br><span class="line"><span class="comment">//DEM数据  </span></span><br><span class="line"><span class="keyword">int</span> *DEM_Data,DEM_N;  </span><br><span class="line"><span class="keyword">int</span> *DEM_Send,*DEM_Recv;  </span><br><span class="line"><span class="keyword">int</span> DEM_Dir[NDIM][<span class="number">2</span>];  </span><br><span class="line"><span class="keyword">int</span> DEMtoLBM[RATE];  </span><br><span class="line">  </span><br><span class="line">FILE *fp1;  </span><br><span class="line">  </span><br><span class="line"><span class="comment">/** rank_IBM指向32int大小的内存,rank_DEM指向8int大小的内存 */</span>  </span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">SetMPIRegion</span><span class="params">()</span>  </span></span><br><span class="line"><span class="function"></span>&#123;  </span><br><span class="line">    N=Size/<span class="number">5</span>;  </span><br><span class="line">    rank_LBM=(<span class="keyword">int</span> *)<span class="built_in">malloc</span>(<span class="keyword">sizeof</span>(<span class="keyword">int</span>)*<span class="number">4</span>*N);  </span><br><span class="line">    rank_DEM=(<span class="keyword">int</span> *)<span class="built_in">malloc</span>(<span class="keyword">sizeof</span>(<span class="keyword">int</span>)*N);  </span><br><span class="line">  </span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i=<span class="number">0</span>; i&lt;<span class="number">4</span>*N; i++)  </span><br><span class="line">        rank_LBM[i]=i; <span class="comment">/** 0-31号进程 */</span>  </span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i=<span class="number">0</span>; i&lt;N; i++)  </span><br><span class="line">        rank_DEM[i]=<span class="number">4</span>*N+i; <span class="comment">/** 32-39号进程 */</span>  </span><br><span class="line">  </span><br><span class="line">    MPI_Comm_group(MPI_COMM_WORLD, &amp;group_WORLD); <span class="comment">/** 定义COMM_WORLD对应的通信组 */</span>  </span><br><span class="line">    MPI_Group_incl(group_WORLD, <span class="number">4</span>*N, rank_LBM, &amp;group_LBM); <span class="comment">/** 基于已有的组group_WORLD,创建新组group_LBM */</span>  </span><br><span class="line">    MPI_Group_incl(group_WORLD, N, rank_DEM, &amp;group_DEM);  </span><br><span class="line">    MPI_Comm_create(MPI_COMM_WORLD, group_LBM, &amp;comm_LBM); <span class="comment">/** 创建对应于通信组group_LBM的通信域comm_LBM */</span>  </span><br><span class="line">    MPI_Comm_create(MPI_COMM_WORLD, group_DEM, &amp;comm_DEM);  </span><br><span class="line">&#125;  </span><br><span class="line">  </span><br><span class="line"><span class="comment">/** 该函数分别按照dem和lbm的方式将一个正方体切割为32和8个区域,对这两种切割方式,分别说明了某个 </span></span><br><span class="line"><span class="comment"> * 进程的前后左右上下分别是哪些进程,以及dem的进程与lbm的进程的互相的对应关系 */</span>  </span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">InitializeProcess</span><span class="params">()</span>  </span></span><br><span class="line"><span class="function"></span>&#123;  </span><br><span class="line">    DEM_Prsnum[<span class="number">0</span>]=<span class="number">2</span>;  </span><br><span class="line">    DEM_Prsnum[<span class="number">1</span>]=<span class="number">2</span>;  </span><br><span class="line">    DEM_Prsnum[<span class="number">2</span>]=<span class="number">2</span>;  </span><br><span class="line">    LBM_Prsnum[<span class="number">0</span>]=<span class="number">4</span>;  </span><br><span class="line">    LBM_Prsnum[<span class="number">1</span>]=<span class="number">4</span>;  </span><br><span class="line">    LBM_Prsnum[<span class="number">2</span>]=<span class="number">2</span>;  </span><br><span class="line">    <span class="comment">/** DEM把一个正方体划分为2*2*2,LBM把它划分成4*4*2,划分的每一块对应一个进程 */</span>  </span><br><span class="line">  </span><br><span class="line">    <span class="keyword">if</span> (Myid&lt;<span class="number">4</span>*N)  </span><br><span class="line">    &#123;  </span><br><span class="line">        <span class="keyword">int</span> XYnum=LBM_Prsnum[<span class="number">0</span>]*LBM_Prsnum[<span class="number">1</span>]; <span class="comment">/** XYnum=16 */</span>  </span><br><span class="line">        <span class="comment">/** 假设第20号进程, Myid=20 */</span>  </span><br><span class="line">        LBM_Prsid[<span class="number">0</span>]=Myid%LBM_Prsnum[<span class="number">0</span>]; <span class="comment">/** LBM_Prsid[0]=0 */</span>  </span><br><span class="line">        LBM_Prsid[<span class="number">1</span>]=(Myid%XYnum)/LBM_Prsnum[<span class="number">0</span>]; <span class="comment">/** LBM_Prsid[1]=1 */</span>  </span><br><span class="line">        LBM_Prsid[<span class="number">2</span>]=Myid/XYnum; <span class="comment">/** LBM_Prsid[2]=1 */</span>  </span><br><span class="line">  </span><br><span class="line">        <span class="built_in">fprintf</span>(fp1,<span class="string">"Prs %3d is (%d %d %d)\n"</span>, Myid,LBM_Prsid[<span class="number">0</span>],LBM_Prsid[<span class="number">1</span>],LBM_Prsid[<span class="number">2</span>]);  </span><br><span class="line">  </span><br><span class="line">        <span class="keyword">int</span> tmp[<span class="number">4</span>]=&#123;<span class="number">1</span>,LBM_Prsnum[<span class="number">0</span>],XYnum,<span class="number">4</span>*N&#125;; <span class="comment">/** &#123;1,4,16,32&#125; */</span>  </span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> i=<span class="number">0</span>; i&lt;NDIM; i++)  </span><br><span class="line">        &#123;  </span><br><span class="line">            <span class="keyword">int</span> pre=Myid-tmp[i];  </span><br><span class="line">            <span class="keyword">int</span> next=Myid+tmp[i];  </span><br><span class="line">  </span><br><span class="line">            <span class="keyword">if</span> (((pre+tmp[i+<span class="number">1</span>])/tmp[i+<span class="number">1</span>])!=((Myid+tmp[i+<span class="number">1</span>])/tmp[i+<span class="number">1</span>]))  </span><br><span class="line">                pre+=tmp[i+<span class="number">1</span>];  </span><br><span class="line">            <span class="keyword">if</span> ((next/tmp[i+<span class="number">1</span>])!=(Myid/tmp[i+<span class="number">1</span>]))  </span><br><span class="line">                next-=tmp[i+<span class="number">1</span>];  </span><br><span class="line">  </span><br><span class="line">            LBM_Dir[i][<span class="number">0</span>]=pre; <span class="comment">/** i=0,pre=23; */</span>  </span><br><span class="line">            LBM_Dir[i][<span class="number">1</span>]=next; <span class="comment">/** i=0,next=21 */</span>  </span><br><span class="line">            <span class="built_in">fprintf</span>(fp1,<span class="string">"Prs %3d: dir %d, pre is %d next is %d\n"</span>,Myid,i,pre,next);  </span><br><span class="line">        &#125;  </span><br><span class="line">  </span><br><span class="line">        <span class="keyword">int</span> temp[<span class="number">4</span>]=&#123;<span class="number">1</span>,DEM_Prsnum[<span class="number">0</span>],DEM_Prsnum[<span class="number">0</span>]*DEM_Prsnum[<span class="number">1</span>],N&#125;;  </span><br><span class="line">        LBMtoDEM=LBM_Prsid[<span class="number">0</span>]/<span class="number">2</span>*temp[<span class="number">0</span>]+LBM_Prsid[<span class="number">1</span>]/<span class="number">2</span>*temp[<span class="number">1</span>]+LBM_Prsid[<span class="number">2</span>]*temp[<span class="number">2</span>]+<span class="number">4</span>*N;  </span><br><span class="line">        <span class="built_in">fprintf</span>(fp1, <span class="string">"Prs %d point Prs %d\n"</span>,Myid,LBMtoDEM);  </span><br><span class="line">    &#125;  </span><br><span class="line">    <span class="keyword">else</span>  </span><br><span class="line">    &#123;  </span><br><span class="line">        <span class="keyword">int</span> XYnum=DEM_Prsnum[<span class="number">0</span>]*DEM_Prsnum[<span class="number">1</span>];  </span><br><span class="line">        <span class="keyword">int</span> DEMid=Myid<span class="number">-4</span>*N;  </span><br><span class="line">        DEM_Prsid[<span class="number">0</span>]=DEMid%DEM_Prsnum[<span class="number">0</span>];  </span><br><span class="line">        DEM_Prsid[<span class="number">1</span>]=(DEMid%XYnum)/DEM_Prsnum[<span class="number">0</span>];  </span><br><span class="line">        DEM_Prsid[<span class="number">2</span>]=DEMid/XYnum;  </span><br><span class="line">  </span><br><span class="line">        <span class="built_in">fprintf</span>(fp1,<span class="string">"Prs %3d is (%d %d %d)\n"</span>, Myid,DEM_Prsid[<span class="number">0</span>],DEM_Prsid[<span class="number">1</span>],DEM_Prsid[<span class="number">2</span>]);  </span><br><span class="line">  </span><br><span class="line">        <span class="keyword">int</span> tmp[<span class="number">4</span>]=&#123;<span class="number">1</span>,DEM_Prsnum[<span class="number">0</span>],XYnum,N&#125;;  </span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> i=<span class="number">0</span>; i&lt;NDIM; i++)  </span><br><span class="line">        &#123;  </span><br><span class="line">            <span class="keyword">int</span> id=Myid<span class="number">-4</span>*N;  </span><br><span class="line">  </span><br><span class="line">            <span class="keyword">int</span> pre=id-tmp[i];  </span><br><span class="line">            <span class="keyword">int</span> next=id+tmp[i];  </span><br><span class="line">  </span><br><span class="line">            <span class="keyword">if</span> (((pre+tmp[i+<span class="number">1</span>])/tmp[i+<span class="number">1</span>])!=((id+tmp[i+<span class="number">1</span>])/tmp[i+<span class="number">1</span>]))  </span><br><span class="line">                pre+=tmp[i+<span class="number">1</span>];  </span><br><span class="line">            <span class="keyword">if</span> ((next/tmp[i+<span class="number">1</span>])!=(id/tmp[i+<span class="number">1</span>]))  </span><br><span class="line">                next-=tmp[i+<span class="number">1</span>];  </span><br><span class="line">  </span><br><span class="line">            DEM_Dir[i][<span class="number">0</span>]=pre;<span class="comment">//+4*N;  </span></span><br><span class="line">            DEM_Dir[i][<span class="number">1</span>]=next;<span class="comment">//+4*N;  </span></span><br><span class="line">            <span class="built_in">fprintf</span>(fp1,<span class="string">"Prs %3d: dir %d, pre is %d next is %d\n"</span>,Myid,i,DEM_Dir[i][<span class="number">0</span>],DEM_Dir[i][<span class="number">1</span>]);  </span><br><span class="line">        &#125;  </span><br><span class="line">  </span><br><span class="line">        <span class="keyword">int</span> temp[<span class="number">4</span>]=&#123;<span class="number">1</span>,LBM_Prsnum[<span class="number">0</span>],LBM_Prsnum[<span class="number">0</span>]*LBM_Prsnum[<span class="number">1</span>],<span class="number">4</span>*N&#125;;  </span><br><span class="line">        <span class="comment">//int dir[4][2]=&#123;(0,0),(1,0),(0,1),(1,1)&#125;;  </span></span><br><span class="line">        <span class="comment">//int dir[4][2]=&#123;(0,1,0,1),(0,0,1,1)&#125;;  </span></span><br><span class="line">        <span class="keyword">int</span> dir[<span class="number">4</span>][<span class="number">2</span>];  </span><br><span class="line">        dir[<span class="number">0</span>][<span class="number">0</span>]=<span class="number">0</span>; dir[<span class="number">0</span>][<span class="number">1</span>]=<span class="number">0</span>;  </span><br><span class="line">        dir[<span class="number">1</span>][<span class="number">0</span>]=<span class="number">1</span>; dir[<span class="number">1</span>][<span class="number">1</span>]=<span class="number">0</span>;  </span><br><span class="line">        dir[<span class="number">2</span>][<span class="number">0</span>]=<span class="number">0</span>; dir[<span class="number">2</span>][<span class="number">1</span>]=<span class="number">1</span>;  </span><br><span class="line">        dir[<span class="number">3</span>][<span class="number">0</span>]=<span class="number">1</span>; dir[<span class="number">3</span>][<span class="number">1</span>]=<span class="number">1</span>;  </span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> i=<span class="number">0</span>; i&lt;<span class="number">4</span>; i++)  </span><br><span class="line">        &#123;  </span><br><span class="line">            DEMtoLBM[i]=(DEM_Prsid[<span class="number">0</span>]*<span class="number">2</span>+dir[i][<span class="number">0</span>])*temp[<span class="number">0</span>]+(DEM_Prsid[<span class="number">1</span>]*<span class="number">2</span>+dir[i][<span class="number">1</span>])*temp[<span class="number">1</span>]+DEM_Prsid[<span class="number">2</span>]*temp[<span class="number">2</span>];  </span><br><span class="line">            <span class="built_in">fprintf</span>(fp1, <span class="string">"Prs %d point Prs %d\n"</span>,Myid,DEMtoLBM[i]);  </span><br><span class="line">        &#125;  </span><br><span class="line">    &#125;  </span><br><span class="line">&#125;  </span><br><span class="line">  </span><br><span class="line"><span class="comment">/** LBM_Data,LBM_Send,LBM_Recv,DEM_Data,DEM_Send,DEM_Recv 均指向200int大小的内存,在每个进程上都分配 */</span>  </span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">ArrayAlloc</span><span class="params">()</span>  </span></span><br><span class="line"><span class="function"></span>&#123;  </span><br><span class="line">    <span class="keyword">if</span> (Myid&lt;<span class="number">4</span>*N)  </span><br><span class="line">    &#123;  </span><br><span class="line">        LBM_Data=(<span class="keyword">int</span> *)<span class="built_in">malloc</span>(<span class="keyword">sizeof</span>(<span class="keyword">int</span>)*MAXN);  </span><br><span class="line">        LBM_Send=(<span class="keyword">int</span> *)<span class="built_in">malloc</span>(<span class="keyword">sizeof</span>(<span class="keyword">int</span>)*MAXN);  </span><br><span class="line">        LBM_Recv=(<span class="keyword">int</span> *)<span class="built_in">malloc</span>(<span class="keyword">sizeof</span>(<span class="keyword">int</span>)*MAXN);  </span><br><span class="line">        <span class="built_in">memset</span>(LBM_Data,<span class="number">0</span>,MAXN*<span class="keyword">sizeof</span>(<span class="keyword">int</span>));  </span><br><span class="line">        <span class="built_in">memset</span>(LBM_Send,<span class="number">0</span>,MAXN*<span class="keyword">sizeof</span>(<span class="keyword">int</span>));  </span><br><span class="line">        <span class="built_in">memset</span>(LBM_Recv,<span class="number">0</span>,MAXN*<span class="keyword">sizeof</span>(<span class="keyword">int</span>));  </span><br><span class="line">    &#125;  </span><br><span class="line">    <span class="keyword">else</span>  </span><br><span class="line">    &#123;  </span><br><span class="line">        DEM_Data=(<span class="keyword">int</span> *)<span class="built_in">malloc</span>(<span class="keyword">sizeof</span>(<span class="keyword">int</span>)*MAXN);  </span><br><span class="line">        DEM_Send=(<span class="keyword">int</span> *)<span class="built_in">malloc</span>(<span class="keyword">sizeof</span>(<span class="keyword">int</span>)*MAXN);  </span><br><span class="line">        DEM_Recv=(<span class="keyword">int</span> *)<span class="built_in">malloc</span>(<span class="keyword">sizeof</span>(<span class="keyword">int</span>)*MAXN);  </span><br><span class="line">        <span class="built_in">memset</span>(DEM_Data,<span class="number">0</span>,MAXN*<span class="keyword">sizeof</span>(<span class="keyword">int</span>));  </span><br><span class="line">        <span class="built_in">memset</span>(DEM_Send,<span class="number">0</span>,MAXN*<span class="keyword">sizeof</span>(<span class="keyword">int</span>));  </span><br><span class="line">        <span class="built_in">memset</span>(DEM_Recv,<span class="number">0</span>,MAXN*<span class="keyword">sizeof</span>(<span class="keyword">int</span>));  </span><br><span class="line">    &#125;  </span><br><span class="line">&#125;  </span><br><span class="line">  </span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">InitializeData</span><span class="params">()</span>  </span></span><br><span class="line"><span class="function"></span>&#123;  </span><br><span class="line">    <span class="comment">/** lbm的数据根据进程号扩大10倍再加1;dem的数据根据进程号-32后扩大20倍再加1 */</span>  </span><br><span class="line">    <span class="keyword">if</span> (Myid&lt;<span class="number">4</span>*N)  </span><br><span class="line">    &#123;  </span><br><span class="line">        LBM_N=<span class="number">10</span>;  </span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> i=<span class="number">0</span>; i&lt;LBM_N; i++)  </span><br><span class="line">        &#123;  </span><br><span class="line">            LBM_Data[i]=Myid*LBM_N+i;  </span><br><span class="line">            <span class="built_in">fprintf</span>(fp1,<span class="string">"%d "</span>,LBM_Data[i]);  </span><br><span class="line">        &#125;  </span><br><span class="line">        <span class="built_in">fprintf</span>(fp1,<span class="string">"\n"</span>);  </span><br><span class="line">    &#125;  </span><br><span class="line">    <span class="keyword">else</span>  </span><br><span class="line">    &#123;  </span><br><span class="line">        DEM_N=<span class="number">20</span>;  </span><br><span class="line">        <span class="keyword">int</span> id=Myid<span class="number">-4</span>*N;  </span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> i=<span class="number">0</span>; i&lt;DEM_N; i++)  </span><br><span class="line">        &#123;  </span><br><span class="line">            DEM_Data[i]=id*DEM_N+i;  </span><br><span class="line">            <span class="built_in">fprintf</span>(fp1,<span class="string">"%d "</span>,DEM_Data[i]);  </span><br><span class="line">        &#125;  </span><br><span class="line">        <span class="built_in">fprintf</span>(fp1,<span class="string">"\n"</span>);  </span><br><span class="line">    &#125;  </span><br><span class="line">&#125;  </span><br><span class="line">  </span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">Init</span><span class="params">()</span>  </span></span><br><span class="line"><span class="function"></span>&#123;  </span><br><span class="line">        SetMPIRegion();  </span><br><span class="line">        InitializeProcess();  </span><br><span class="line">        ArrayAlloc();  </span><br><span class="line">        InitializeData();  </span><br><span class="line">&#125;  </span><br><span class="line">  </span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">LBMMPI</span><span class="params">()</span>  </span></span><br><span class="line"><span class="function"></span>&#123;  </span><br><span class="line">    <span class="keyword">int</span> SendNum,RecvNum;  </span><br><span class="line">    SendNum=Myid*LBM_N/<span class="number">4</span>/N; <span class="comment">/** myid=20,sendNum=6; myid=32,sendNum=10 */</span>  </span><br><span class="line">  </span><br><span class="line">    <span class="built_in">fprintf</span>(fp1,<span class="string">"Send to neighbour LBM process: "</span>);  </span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i=<span class="number">0</span>; i&lt;SendNum; i++)  </span><br><span class="line">    &#123;  </span><br><span class="line">        LBM_Send[i]=LBM_Data[i];  </span><br><span class="line">        <span class="built_in">fprintf</span>(fp1,<span class="string">"%d "</span>,LBM_Send[i]);  </span><br><span class="line">    &#125;  </span><br><span class="line">    <span class="built_in">fprintf</span>(fp1,<span class="string">"\n"</span>);  </span><br><span class="line">    fflush(fp1);  </span><br><span class="line">  </span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i=<span class="number">0</span>; i&lt;NDIM; i++)  </span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> j=<span class="number">0</span>; j&lt;<span class="number">2</span>; j++)  </span><br><span class="line">        &#123;  </span><br><span class="line">            MPI_Status status;  </span><br><span class="line">            MPI_Sendrecv(&amp;SendNum,<span class="number">1</span>,MPI_INT,LBM_Dir[i][j],<span class="number">0</span>,&amp;RecvNum,<span class="number">1</span>,MPI_INT,LBM_Dir[i][<span class="number">1</span>-j],<span class="number">0</span>,comm_LBM,&amp;status);  </span><br><span class="line">            <span class="comment">/** 对于每个进程来说,LBM_Dir[i][j]=next,也就是当前进程要把数据发到的地址;同时,当前进程从LBM_Dir[i][j-1]收数据 </span></span><br><span class="line"><span class="comment">             * i指的是xyz这三个方向 */</span>  </span><br><span class="line">            MPI_Sendrecv(LBM_Send,SendNum,MPI_INT,LBM_Dir[i][j],<span class="number">0</span>,LBM_Recv,RecvNum,MPI_INT,LBM_Dir[i][<span class="number">1</span>-j],<span class="number">0</span>,comm_LBM,&amp;status);  </span><br><span class="line">            <span class="comment">//MPI_Barrier(MPI_COMM_WORLD);  </span></span><br><span class="line">            <span class="built_in">fprintf</span>(fp1,<span class="string">"Recv from neighbour LBM process %d: "</span>,LBM_Dir[i][<span class="number">1</span>-j]);  </span><br><span class="line">            <span class="keyword">for</span> (<span class="keyword">int</span> k=<span class="number">0</span>; k&lt;RecvNum; k++)  </span><br><span class="line">            &#123;  </span><br><span class="line">                <span class="built_in">fprintf</span>(fp1,<span class="string">"%d "</span>,LBM_Recv[k]);  </span><br><span class="line">                fflush(fp1);  </span><br><span class="line">            &#125;  </span><br><span class="line">            <span class="built_in">fprintf</span>(fp1,<span class="string">"\n"</span>);  </span><br><span class="line">            fflush(fp1);  </span><br><span class="line">        &#125;  </span><br><span class="line">  </span><br><span class="line">    <span class="built_in">fprintf</span>(fp1,<span class="string">"------------------------------------\n"</span>);  </span><br><span class="line">    fflush(fp1);  </span><br><span class="line">&#125;  </span><br><span class="line">  </span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">DEMMPI</span><span class="params">()</span>  </span></span><br><span class="line"><span class="function"></span>&#123;  </span><br><span class="line">    <span class="keyword">int</span> SendNum,RecvNum;  </span><br><span class="line">    <span class="keyword">int</span> id=Myid<span class="number">-4</span>*N;  </span><br><span class="line">    SendNum=id*DEM_N/N;  </span><br><span class="line">  </span><br><span class="line">    <span class="built_in">fprintf</span>(fp1,<span class="string">"Send to neighbour DEM process: "</span>);  </span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i=<span class="number">0</span>; i&lt;SendNum; i++)  </span><br><span class="line">    &#123;  </span><br><span class="line">        DEM_Send[i]=DEM_Data[i];  </span><br><span class="line">        <span class="built_in">fprintf</span>(fp1,<span class="string">"%d "</span>,DEM_Send[i]);  </span><br><span class="line">    &#125;  </span><br><span class="line">    <span class="built_in">fprintf</span>(fp1,<span class="string">"\n"</span>);  </span><br><span class="line">    fflush(fp1);  </span><br><span class="line">  </span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i=<span class="number">0</span>; i&lt;NDIM; i++)  </span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> j=<span class="number">0</span>; j&lt;<span class="number">2</span>; j++)  </span><br><span class="line">        &#123;  </span><br><span class="line">            MPI_Status status1;  </span><br><span class="line">            MPI_Sendrecv(&amp;SendNum,<span class="number">1</span>,MPI_INT,DEM_Dir[i][j],<span class="number">0</span>,&amp;RecvNum,<span class="number">1</span>,MPI_INT,DEM_Dir[i][<span class="number">1</span>-j],<span class="number">0</span>,comm_DEM,&amp;status1);  </span><br><span class="line">            MPI_Sendrecv(DEM_Send,SendNum,MPI_INT,DEM_Dir[i][j],<span class="number">0</span>,DEM_Recv,RecvNum,MPI_INT,DEM_Dir[i][<span class="number">1</span>-j],<span class="number">0</span>,comm_DEM,&amp;status1);  </span><br><span class="line">            <span class="comment">//MPI_Barrier(MPI_COMM_WORLD);  </span></span><br><span class="line">            <span class="built_in">fprintf</span>(fp1,<span class="string">"Recv from neighbour DEM process %d: "</span>,DEM_Dir[i][<span class="number">1</span>-j]);  </span><br><span class="line">            <span class="keyword">for</span> (<span class="keyword">int</span> k=<span class="number">0</span>; k&lt;RecvNum; k++)  </span><br><span class="line">            &#123;  </span><br><span class="line">                <span class="built_in">fprintf</span>(fp1,<span class="string">"%d "</span>,DEM_Recv[k]);  </span><br><span class="line">                fflush(fp1);  </span><br><span class="line">            &#125;  </span><br><span class="line">            <span class="built_in">fprintf</span>(fp1,<span class="string">"\n"</span>);  </span><br><span class="line">            fflush(fp1);  </span><br><span class="line">        &#125;  </span><br><span class="line">  </span><br><span class="line">    <span class="built_in">fprintf</span>(fp1,<span class="string">"------------------------------------\n"</span>);  </span><br><span class="line">    fflush(fp1);  </span><br><span class="line">&#125;  </span><br><span class="line">  </span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">SendtoDEM</span><span class="params">()</span>  </span></span><br><span class="line"><span class="function"></span>&#123;  </span><br><span class="line">    <span class="keyword">int</span> SendNum=<span class="number">5</span>;  </span><br><span class="line">  </span><br><span class="line">    <span class="built_in">fprintf</span>(fp1,<span class="string">"Send to relative DEM process: "</span>);  </span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i=<span class="number">0</span>; i&lt;SendNum; i++)  </span><br><span class="line">    &#123;  </span><br><span class="line">        LBM_Send[i]=LBM_Data[i];  </span><br><span class="line">        <span class="built_in">fprintf</span>(fp1,<span class="string">"%d "</span>,LBM_Send[i]);  </span><br><span class="line">    &#125;  </span><br><span class="line">    <span class="built_in">fprintf</span>(fp1,<span class="string">"\n"</span>);  </span><br><span class="line">    fflush(fp1);  </span><br><span class="line">  </span><br><span class="line">    MPI_Request request[<span class="number">2</span>];  </span><br><span class="line">    MPI_Status status[<span class="number">2</span>];  </span><br><span class="line">  </span><br><span class="line">    MPI_Isend(&amp;SendNum,<span class="number">1</span>,MPI_INT,LBMtoDEM,<span class="number">0</span>,MPI_COMM_WORLD,&amp;request[<span class="number">0</span>]);  </span><br><span class="line">    <span class="comment">//MPI_Send(&amp;SendNum,1,MPI_INT,LBMtoDEM,0,MPI_COMM_WORLD);  </span></span><br><span class="line">  </span><br><span class="line">    MPI_Wait(&amp;request[<span class="number">0</span>],&amp;status[<span class="number">0</span>]);  </span><br><span class="line">  </span><br><span class="line">    MPI_Isend(LBM_Send,SendNum,MPI_INT,LBMtoDEM,<span class="number">0</span>,MPI_COMM_WORLD,&amp;request[<span class="number">1</span>]);  </span><br><span class="line">    <span class="comment">//MPI_Send(LBM_Send,SendNum,MPI_INT,LBMtoDEM,0,MPI_COMM_WORLD);  </span></span><br><span class="line">  </span><br><span class="line">    MPI_Wait(&amp;request[<span class="number">1</span>],&amp;status[<span class="number">1</span>]);  </span><br><span class="line">  </span><br><span class="line">    <span class="comment">//MPI_Barrier(MPI_COMM_WORLD);  </span></span><br><span class="line">  </span><br><span class="line"><span class="comment">//  for (int i=0; i&lt;2; i++)  </span></span><br><span class="line"><span class="comment">//      MPI_Wait(&amp;request[i],&amp;status[i]);  </span></span><br><span class="line">  </span><br><span class="line">    <span class="built_in">fprintf</span>(fp1,<span class="string">"------------------------------------\n"</span>);  </span><br><span class="line">    fflush(fp1);  </span><br><span class="line">&#125;  </span><br><span class="line">  </span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">RecvfromLBM</span><span class="params">()</span>  </span></span><br><span class="line"><span class="function"></span>&#123;  </span><br><span class="line">    <span class="keyword">int</span> RecvNum;  </span><br><span class="line">  </span><br><span class="line">    MPI_Request request[<span class="number">4</span>];  </span><br><span class="line">    MPI_Status status[<span class="number">4</span>];  </span><br><span class="line">  </span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i=<span class="number">0</span>; i&lt;<span class="number">4</span>; i++)  </span><br><span class="line">    &#123;  </span><br><span class="line">        MPI_Irecv(&amp;RecvNum,<span class="number">1</span>,MPI_INT,DEMtoLBM[i],<span class="number">0</span>,MPI_COMM_WORLD,&amp;request[i]);  </span><br><span class="line">        <span class="comment">//MPI_Recv(&amp;RecvNum,1,MPI_INT,DEMtoLBM[i],0,MPI_COMM_WORLD,&amp;status);  </span></span><br><span class="line">    &#125;  </span><br><span class="line">  </span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i=<span class="number">0</span>; i&lt;<span class="number">4</span>; i++)  </span><br><span class="line">        MPI_Wait(&amp;request[i],&amp;status[i]);  </span><br><span class="line">  </span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i=<span class="number">0</span>; i&lt;<span class="number">4</span>; i++)  </span><br><span class="line">    &#123;  </span><br><span class="line">        MPI_Irecv(DEM_Recv,RecvNum,MPI_INT,DEMtoLBM[i],<span class="number">0</span>,MPI_COMM_WORLD,&amp;request[i]);  </span><br><span class="line">        <span class="comment">//MPI_Recv(DEM_Recv,RecvNum,MPI_INT,DEMtoLBM[i],0,MPI_COMM_WORLD,&amp;status);  </span></span><br><span class="line">  </span><br><span class="line"><span class="comment">//      fprintf(fp1,"Recv from relative LBM process %d of rank %d: ",DEMtoLBM[i],i);  </span></span><br><span class="line">        <span class="built_in">fprintf</span>(fp1,<span class="string">"Recv data Length %d from LBM proce111ss %d of rank %d\n"</span>,RecvNum,DEMtoLBM[i],i);  </span><br><span class="line">        fflush(fp1);  </span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> k=<span class="number">0</span>; k&lt;RecvNum; k++)  </span><br><span class="line">        &#123;  </span><br><span class="line">            <span class="built_in">fprintf</span>(fp1,<span class="string">"%d "</span>,DEM_Recv[k]);  </span><br><span class="line">            fflush(fp1);  </span><br><span class="line">        &#125;  </span><br><span class="line">        <span class="built_in">fprintf</span>(fp1,<span class="string">"\n"</span>);  </span><br><span class="line">        fflush(fp1);  </span><br><span class="line">    &#125;  </span><br><span class="line">  </span><br><span class="line">    <span class="comment">//MPI_Barrier(MPI_COMM_WORLD);  </span></span><br><span class="line">  </span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i=<span class="number">0</span>; i&lt;<span class="number">4</span>; i++)  </span><br><span class="line">        MPI_Wait(&amp;request[i],&amp;status[i]);  </span><br><span class="line">  </span><br><span class="line">    <span class="built_in">fprintf</span>(fp1,<span class="string">"------------------------------------\n"</span>);  </span><br><span class="line">    fflush(fp1);  </span><br><span class="line">&#125;  </span><br><span class="line">  </span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">SendtoLBM</span><span class="params">()</span>  </span></span><br><span class="line"><span class="function"></span>&#123;  </span><br><span class="line">    <span class="keyword">int</span> SendNum=<span class="number">10</span>;  </span><br><span class="line">  </span><br><span class="line">    <span class="built_in">fprintf</span>(fp1,<span class="string">"Send to relative LBM process: "</span>);  </span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i=<span class="number">0</span>; i&lt;SendNum; i++)  </span><br><span class="line">    &#123;  </span><br><span class="line">        DEM_Send[i]=DEM_Data[i];  </span><br><span class="line">        <span class="built_in">fprintf</span>(fp1,<span class="string">"%d "</span>,DEM_Send[i]);  </span><br><span class="line">    &#125;  </span><br><span class="line">    <span class="built_in">fprintf</span>(fp1,<span class="string">"\n"</span>);  </span><br><span class="line">    fflush(fp1);  </span><br><span class="line">  </span><br><span class="line">    MPI_Request request[<span class="number">4</span>];  </span><br><span class="line">    MPI_Status status[<span class="number">4</span>];  </span><br><span class="line">  </span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i=<span class="number">0</span>; i&lt;<span class="number">4</span>; i++)  </span><br><span class="line">    &#123;  </span><br><span class="line">        MPI_Isend(&amp;SendNum,<span class="number">1</span>,MPI_INT,DEMtoLBM[i],<span class="number">0</span>,MPI_COMM_WORLD,&amp;request[i]);  </span><br><span class="line">        <span class="comment">//MPI_Send(&amp;SendNum,1,MPI_INT,DEMtoLBM[i],0,MPI_COMM_WORLD);  </span></span><br><span class="line">    &#125;  </span><br><span class="line">  </span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i=<span class="number">0</span>; i&lt;<span class="number">4</span>; i++)  </span><br><span class="line">        MPI_Wait(&amp;request[i],&amp;status[i]);  </span><br><span class="line">  </span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i=<span class="number">0</span>; i&lt;<span class="number">4</span>; i++)  </span><br><span class="line">    &#123;  </span><br><span class="line">        MPI_Isend(DEM_Send,SendNum,MPI_INT,DEMtoLBM[i],<span class="number">0</span>,MPI_COMM_WORLD,&amp;request[i]);  </span><br><span class="line">        <span class="comment">//MPI_Send(DEM_Send,SendNum,MPI_INT,DEMtoLBM[i],0,MPI_COMM_WORLD);  </span></span><br><span class="line">    &#125;  </span><br><span class="line">  </span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i=<span class="number">0</span>; i&lt;<span class="number">4</span>; i++)  </span><br><span class="line">        MPI_Wait(&amp;request[i],&amp;status[i]);  </span><br><span class="line">  </span><br><span class="line">    <span class="built_in">fprintf</span>(fp1,<span class="string">"------------------------------------\n"</span>);  </span><br><span class="line">    fflush(fp1);  </span><br><span class="line">&#125;  </span><br><span class="line">  </span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">RecvfromDEM</span><span class="params">()</span>  </span></span><br><span class="line"><span class="function"></span>&#123;  </span><br><span class="line">    <span class="keyword">int</span> RecvNum;  </span><br><span class="line">  </span><br><span class="line">    MPI_Request request[<span class="number">2</span>];  </span><br><span class="line">    MPI_Status status[<span class="number">2</span>];  </span><br><span class="line">  </span><br><span class="line">    MPI_Irecv(&amp;RecvNum,<span class="number">1</span>,MPI_INT,LBMtoDEM,<span class="number">0</span>,MPI_COMM_WORLD,&amp;request[<span class="number">0</span>]);  </span><br><span class="line">    <span class="comment">//MPI_Recv(&amp;RecvNum,1,MPI_INT,LBMtoDEM,0,MPI_COMM_WORLD,&amp;status);  </span></span><br><span class="line">  </span><br><span class="line">    MPI_Wait(&amp;request[<span class="number">0</span>],&amp;status[<span class="number">0</span>]);  </span><br><span class="line">  </span><br><span class="line">    MPI_Irecv(LBM_Recv,RecvNum,MPI_INT,LBMtoDEM,<span class="number">0</span>,MPI_COMM_WORLD,&amp;request[<span class="number">1</span>]);  </span><br><span class="line">    <span class="comment">//MPI_Recv(LBM_Recv,RecvNum,MPI_INT,LBMtoDEM,0,MPI_COMM_WORLD,&amp;status);  </span></span><br><span class="line">  </span><br><span class="line">    MPI_Wait(&amp;request[<span class="number">1</span>],&amp;status[<span class="number">1</span>]);  </span><br><span class="line">  </span><br><span class="line"><span class="comment">//  fprintf(fp1,"Recv from relative LBM process %d of rank %d: ",DEMtoLBM[i],i);  </span></span><br><span class="line">    <span class="built_in">fprintf</span>(fp1,<span class="string">"Recv data Length %d from DEM process %d\n"</span>,RecvNum,LBMtoDEM);  </span><br><span class="line">    fflush(fp1);  </span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> k=<span class="number">0</span>; k&lt;RecvNum; k++)  </span><br><span class="line">    &#123;  </span><br><span class="line">        <span class="built_in">fprintf</span>(fp1,<span class="string">"%d "</span>,LBM_Recv[k]);  </span><br><span class="line">        fflush(fp1);  </span><br><span class="line">    &#125;  </span><br><span class="line">    <span class="built_in">fprintf</span>(fp1,<span class="string">"\n"</span>);  </span><br><span class="line">    fflush(fp1);  </span><br><span class="line">  </span><br><span class="line"><span class="comment">//  for (int i=0; i&lt;2; i++)  </span></span><br><span class="line"><span class="comment">//      MPI_Wait(&amp;request[i],&amp;status[i]);  </span></span><br><span class="line">  </span><br><span class="line">    <span class="built_in">fprintf</span>(fp1,<span class="string">"------------------------------------\n"</span>);  </span><br><span class="line">    fflush(fp1);  </span><br><span class="line">&#125;  </span><br><span class="line">  </span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">one_step</span><span class="params">()</span>  </span></span><br><span class="line"><span class="function"></span>&#123;  </span><br><span class="line">    <span class="keyword">if</span> (Myid&lt;<span class="number">4</span>*N)  </span><br><span class="line">    &#123;  </span><br><span class="line">        <span class="comment">//LBM计算  </span></span><br><span class="line">        <span class="comment">//one_step_LBM();  </span></span><br><span class="line">        <span class="comment">//LBM内MPI通讯  </span></span><br><span class="line">        LBMMPI();  </span><br><span class="line">  </span><br><span class="line">        <span class="comment">//传流场数据给DEM  </span></span><br><span class="line">        SendtoDEM();  </span><br><span class="line">        <span class="comment">//接受DEM颗粒数据  </span></span><br><span class="line">        RecvfromDEM();  </span><br><span class="line">    &#125;  </span><br><span class="line">    <span class="keyword">else</span>  </span><br><span class="line">    &#123;  </span><br><span class="line">        <span class="comment">//DEM计算  </span></span><br><span class="line">        <span class="comment">//one_step_DEM();  </span></span><br><span class="line">        <span class="comment">//DEM内MPI通讯  </span></span><br><span class="line">        DEMMPI();  </span><br><span class="line">  </span><br><span class="line">        <span class="comment">//接受LBM流场数据  </span></span><br><span class="line">        RecvfromLBM();  </span><br><span class="line">        <span class="comment">//传颗粒数据给LBM  </span></span><br><span class="line">        SendtoLBM();  </span><br><span class="line">    &#125;  </span><br><span class="line">  </span><br><span class="line">&#125;  </span><br><span class="line">  </span><br><span class="line">  </span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">Solve</span><span class="params">()</span>  </span></span><br><span class="line"><span class="function"></span>&#123;  </span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i=<span class="number">0</span>; i&lt;<span class="number">2</span>; i++)  </span><br><span class="line">    &#123;  </span><br><span class="line">        one_step();  </span><br><span class="line">    &#125;  </span><br><span class="line">&#125;  </span><br><span class="line">  </span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">(<span class="keyword">int</span> argc, <span class="keyword">char</span> *argv[])</span>  </span></span><br><span class="line"><span class="function"></span>&#123;  </span><br><span class="line">    MPI_Init(&amp;argc,&amp;argv);  </span><br><span class="line">    MPI_Comm_size(MPI_COMM_WORLD,&amp;Size);  </span><br><span class="line">    MPI_Comm_rank(MPI_COMM_WORLD,&amp;Myid);  </span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"Prs %4d:Program Start\n"</span>,Myid);  </span><br><span class="line">  </span><br><span class="line">    <span class="keyword">char</span> sN[<span class="number">200</span>]=<span class="string">""</span>,MYID[<span class="number">200</span>];  </span><br><span class="line">    <span class="built_in">strcat</span>(sN,<span class="string">"DebugInfo"</span>);  </span><br><span class="line">    <span class="built_in">sprintf</span>(MYID,<span class="string">"%d"</span>,Myid);  </span><br><span class="line">    <span class="keyword">int</span> nzero=<span class="keyword">int</span>(<span class="built_in">log10</span>(<span class="keyword">double</span>(Size))-(Myid!=<span class="number">0</span>?<span class="keyword">int</span>(<span class="built_in">log10</span>(<span class="keyword">double</span>(Myid))):<span class="number">0</span>));  </span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i=<span class="number">0</span>; i&lt;nzero; i++) <span class="built_in">strcat</span>(sN,<span class="string">"0"</span>);  </span><br><span class="line">    <span class="built_in">strcat</span>(sN,MYID);  </span><br><span class="line">    <span class="built_in">strcat</span>(sN,<span class="string">".txt"</span>);  </span><br><span class="line">    fp1=fopen(sN,<span class="string">"w"</span>);  </span><br><span class="line">  </span><br><span class="line">    Init();  </span><br><span class="line">    Solve();  </span><br><span class="line">    <span class="comment">//Memfree();  </span></span><br><span class="line">  </span><br><span class="line">    fclose(fp1);  </span><br><span class="line">  </span><br><span class="line">    MPI_Finalize();  </span><br><span class="line">  </span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;  </span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/kity@2.0.4/dist/kity.min.js"></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/kityminder-core@1.4.50/dist/kityminder.core.min.js"></script><script defer="true" type="text/javascript" src="https://cdn.jsdelivr.net/npm/hexo-simple-mindmap@0.2.0/dist/mindmap.min.js"></script><link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/hexo-simple-mindmap@0.2.0/dist/mindmap.min.css">
    </div>

    
    
    
      
  <div class="popular-posts-header">相关文章</div>
  <ul class="popular-posts">
    <li class="popular-posts-item">
      <div class="popular-posts-title"><a href="/posts/18454/" rel="bookmark">MPI学习记录（一）</a></div>
    </li>
    <li class="popular-posts-item">
      <div class="popular-posts-title"><a href="/posts/50341/" rel="bookmark">MPI进程通讯头文件</a></div>
    </li>
    <li class="popular-posts-item">
      <div class="popular-posts-title"><a href="/posts/59233/" rel="bookmark">MPI程序的GDB调试</a></div>
    </li>
    <li class="popular-posts-item">
      <div class="popular-posts-title"><a href="/posts/22859/" rel="bookmark">MPI三维数据传递</a></div>
    </li>
    <li class="popular-posts-item">
      <div class="popular-posts-title"><a href="/posts/55404/" rel="bookmark">MPI学习记录（二）</a></div>
    </li>
  </ul>

        

<div>
<ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者： </strong>ChiangYung
  </li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="https://chiangyung.github.io/posts/35856/" title="LBM-MPI测试程序">https://chiangyung.github.io/posts/35856/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" rel="noopener" target="_blank"><i class="fab fa-fw fa-creative-commons"></i>BY-NC-SA</a> 许可协议。转载请注明出处！
  </li>
</ul>
</div>


      <footer class="post-footer">
          
          <div class="post-tags">
              <a href="/tags/Programming/" rel="tag"><i class="fa fa-tag"></i> Programming</a>
              <a href="/tags/C/" rel="tag"><i class="fa fa-tag"></i> C++</a>
              <a href="/tags/MPI/" rel="tag"><i class="fa fa-tag"></i> MPI</a>
              <a href="/tags/Parallel-Computing/" rel="tag"><i class="fa fa-tag"></i> Parallel Computing</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/posts/34080/" rel="prev" title="G++与NVCC混合编译">
      <i class="fa fa-chevron-left"></i> G++与NVCC混合编译
    </a></div>
      <div class="post-nav-item">
    <a href="/posts/14121/" rel="next" title="调试NAN">
      调试NAN <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="ChiangYung"
      src="/upload/E8.png">
  <p class="site-author-name" itemprop="name">ChiangYung</p>
  <div class="site-description" itemprop="description">我于蒙昧之中，探寻宇宙万物。</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">41</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">3</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">26</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/chiangyung" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;chiangyung" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i></a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:chiangyoung@outlook.com" title="E-Mail → mailto:chiangyoung@outlook.com" rel="noopener" target="_blank"><i class="fa fa-envelope fa-fw"></i></a>
      </span>
  </div>
  <div class="cc-license motion-element" itemprop="license">
    <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" class="cc-opacity" rel="noopener" target="_blank"><img src="/images/cc-by-nc-sa.svg" alt="Creative Commons"></a>
  </div>


  <div class="links-of-blogroll motion-element">
    <div class="links-of-blogroll-title"><i class="fa fa-link fa-fw"></i>
      友情链接
    </div>
    <ul class="links-of-blogroll-list">
        <li class="links-of-blogroll-item">
          <a href="http://openfoamwiki.net/index.php/Main_Page" title="http:&#x2F;&#x2F;openfoamwiki.net&#x2F;index.php&#x2F;Main_Page" rel="noopener" target="_blank">OpenFOAMWiki</a>
        </li>
    </ul>
  </div>

      </div>
        <div class="back-to-top motion-element">
          <i class="fa fa-arrow-up"></i>
          <span>0%</span>
        </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">ChiangYung</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-area"></i>
    </span>
    <span title="站点总字数">207k</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
    <span title="站点阅读时长">3:08</span>
</div>


  <script src='https://unpkg.com/mermaid@7.1.2/dist/mermaid.min.js'></script>
    <script>
    if (window.mermaid) {
      mermaid.initialize({theme: 'forest'});
    }
  </script>


        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>

<script src="/js/kity.min.js"></script>

<script src="/js/kityminder.core.min.js"></script>

<script src="/js/mindmap.js"></script>

<script src="/js/mindmap.min.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  
  <script>
    (function(){
      var bp = document.createElement('script');
      var curProtocol = window.location.protocol.split(':')[0];
      bp.src = (curProtocol === 'https') ? 'https://zz.bdstatic.com/linksubmit/push.js' : 'http://push.zhanzhang.baidu.com/push.js';
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(bp, s);
    })();
  </script>




  
<script src="/js/local-search.js"></script>











<script>
if (document.querySelectorAll('pre.mermaid').length) {
  NexT.utils.getScript('//cdn.jsdelivr.net/npm/mermaid@8/dist/mermaid.min.js', () => {
    mermaid.initialize({
      theme    : 'forest',
      logLevel : 3,
      flowchart: { curve     : 'linear' },
      gantt    : { axisFormat: '%m/%d/%Y' },
      sequence : { actorMargin: 50 }
    });
  }, window.mermaid);
}
</script>


  

  

  

</body>
</html>
